package com.fuxue.mapper;

import com.fuxue.dto.*;
import com.fuxue.entity.AllFiled;
import com.fuxue.entity.Filed;
import com.fuxue.entity.Server;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface ServerMapper {
    /**
     * 根据用户名查询员工
     * @param
     * @return
     */
    @Select("select * from server where server_name = #{servername}")
    Server getByUsername(String servername);
    @Insert("insert into server (server_hao, name, password, server_name, phone,creat_time) " +
            "values " +
            "(#{serverHao},#{name},#{password},#{serverName},#{phone},#{creatTime})")
    void insert (ServerDTO serverDTO);
    /*
    根据id查询服务者全部信息
     */
    @Select("select * from server where server_id = #{id}")
    Server getById(Integer id);

    @Select("select filed_name from filed where server_id = #{id}")
    ArrayList<String> getFiledById(Integer id);
    @Delete("delete from filed where server_id = #{id}")
    void deleteFiledById(Integer id);

    void insertFiled(List<String> fileds,Integer id);
    //根据id更改头像
    

    //根据id更改用户名
    @Update("update server set server_name = #{serverName} where server_id = #{serverId}")
    void updateNameById(ServerUpNameDTO serverUpNameDTO);

    //修改密码中的一部分
    @Select("select * from server where server_id = #{id}")
    Server getServerById(Integer id);
    @Update("UPDATE server SET password = #{newpassword} WHERE server_id = #{id}")
    void UpdateNewPassword(Integer id, String newpassword);

    @Select("select server_id from server where server_hao = #{serverhao}")
    Integer getIdByHao(String serverHao);

    @Update("UPDATE server set avatar = #{avatar} where server_id = #{serverId}")
    void updateAdvatar(ServerUpAdvateDTO serverUpAdvateDTO);

    @Update("UPDATE answer set server_avatar = #{avatar} where server_id = #{serverId}")
    void updateAnserAdvatar(ServerUpAdvateDTO serverUpAdvateDTO);

    @Update("UPDATE question set server_name = #{serverName} where server_id = #{serverId}")
    void updateQuestionName(ServerUpNameDTO serverUpNameDTO);

    @Update("UPDATE answer set server_name = #{serverName} where server_id = #{serverId}")
    void updateAnserName(ServerUpNameDTO serverUpNameDTO);

    @Select("select * from allfiled")
    List<AllFiled> selectAllFiled();
@Update("update server set point = point - 0 where server_id = #{serverId}")
    void updatePoint(Integer serverId, HelpTunDTO helpTunDTO);
}



















